import { request } from "@/utils/service"
import type * as MerchantApply from "./types/merchant-apply"
import type * as Merchant from "./types/merchant"

/** 获取商户入驻申请列表 */
export function getMerchantApplyDataApi(params: MerchantApply.GetMerchantApplyRequestData) {
  return request<MerchantApply.MerchantApplyResponseData>({
    url: "/merchant/apply/list",
    method: "get",
    params
  })
}

/** 审核商户入驻申请 */
export function auditMerchantApplyApi(data: MerchantApply.AuditMerchantApplyRequestData) {
  return request({
    url: "/merchant/apply/audit",
    method: "post",
    data
  })
}

/** 获取商户信息列表 */
export function getMerchantDataApi(params: Merchant.GetMerchantRequestData) {
  return request<Merchant.MerchantResponseData>({
    url: "/merchant/list",
    method: "get",
    params
  })
}

/** 更新商户信息 */
export function updateMerchantApi(data: Merchant.UpdateMerchantRequestData) {
  return request({
    url: "/merchant/update",
    method: "post",
    data
  })
}

/** 设置商户排序号 */
export function setMerchantSeqNoApi(merchantId: number, seqNo: number, seqExpireDate?: string) {
  const params: any = { merchantId, seqNo }
  if (seqExpireDate) {
    params.seqExpireDate = seqExpireDate
  }
  return request({
    url: "/merchant/setSeqNo",
    method: "put",
    params
  })
}